#include "Ball.h"

//STL
#include <iostream>

//Graphics
#include "../Math/Vector.h"

//GLUT
#include "../Graphics/GLUT.h"

//Misc
#include "../Utilities.h"
#include "../Graphics/Renderable.h"

using namespace Game;
using namespace Math;

Ball::Ball(int num, float radius, Renderable* parent):	Drawable(parent, true), 
														Physics::Disc(radius), 
														Physics::Movable()
{
	setNumber(num);

	//Setup the quadric
	_quadric=gluNewQuadric();
	gluQuadricNormals(_quadric, GLU_SMOOTH);
	gluQuadricTexture(_quadric, GLU_TRUE);
}

/**********
* GETTERS *
**********/
int Ball::number() const
{
	return _number;
}

/**********
* SETTERS *
**********/
void Ball::setNumber(int num)
{
	_number=num;
}

/**********
* DRAWING *
**********/
void Ball::redraw()
{
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	//Material properties
	GLfloat mat_specular[]={0.4f,0.4f,0.4f,0.4f};
	GLfloat mat_shininess[]={100.0f};

	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
	glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

	//Set beige color
	glColor3f(0.9f,0.9f,0.8f);
	gluSphere(_quadric,_radius,72,72);

}

void Ball::setPosition(const Point& pos)
{
	Drawable::setPosition(pos);
	_center=_position;
}

void Ball::move(const Point& pos)
{
	Drawable::move(pos);
	_center=_position;
}

void Ball::move(const Vector& amount)
{
	Drawable::move(amount);
	_center=_position;
}
